<?php
/**
 * Created by IntelliJ IDEA.
 * User: HXL
 * Date: 2019/5/15
 * Time: 14:21
 */
namespace app\order\controller;

/**
 * 导出订单表--20190515
 * Class ExportExcel
 * @package app\order\controller
 */
class ExportExcel {

    /**
     * 导出订单excel--订单执行
     * @throws \PHPExcel_Exception
     * @throws \PHPExcel_Writer_Exception
     */
    public function exportExecOrder($data){
        Vendor('phpexcel.PHPExcel');
        Vendor('phpexcel.PHPExcel.IOFactory');
        Vendor('phpexcel.PHPExcel.Reader.Excel5');
        Vendor('phpexcel.PHPExcel.Writer.Excel2007');

        $phpexcel = new \PHPExcel();
        $phpexcel->getActiveSheet()->setTitle("订单执行表");
        //var_dump($phpCreate);exit();
        // 设置单元格高度
        // 所有单元格默认高度
        $phpexcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(25);
        // 第一行的默认高度
        $phpexcel->getActiveSheet()->getRowDimension('1')->setRowHeight(30);
        // 垂直居中
        $phpexcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
        // 设置水平居中
        $phpexcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        //Excel表格式
            $letter = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W');
        //设置表头
        $tableheader = array('订单执行编号','订单评审号','国家','客户','业务部','生产状态','发货状态','模块类型','模块订单号','模块数量',
            '模块下单开始时间','模块下单结束时间','订单数量','基表订单号','基表组装开始时间','基表组装完成时间','表号长度',
            '表号','制造商','生产负责人','生产数据校验','订单金额','备注');
        //填充表头信息
        for($i = 0;$i < count($tableheader);$i++) {
            $phpexcel->getActiveSheet()->setCellValue("$letter[$i]1","$tableheader[$i]");
        }
        //设置标题字体加粗和大小
        $phpexcel->getActiveSheet()->getStyle( 'A1:W1')->getFont()->setSize(12);
        $phpexcel->getActiveSheet()->getStyle( 'A1:W1')->getFont()->setBold(true);
        $phpexcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('E')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('J')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('L')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('M')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('N')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('O')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('P')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('Q')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('R')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('S')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('T')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('U')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('V')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('W')->setWidth(15);
        //数据
        //填充表格信息
        $rowIndex = 2;
        for ($i=0;$i<count($data);$i++) {
            $phpexcel->getActiveSheet()->setCellValue("A".$rowIndex,$data[$i]['oid_exec']);
            $phpexcel->getActiveSheet()->setCellValue("B".$rowIndex,$data[$i]['oid']);
            $phpexcel->getActiveSheet()->setCellValue("C".$rowIndex,$data[$i]['state']);
            $phpexcel->getActiveSheet()->setCellValue("D".$rowIndex,$data[$i]['client']);
            $phpexcel->getActiveSheet()->setCellValue("E".$rowIndex,$data[$i]['sale']);
            switch ($data[$i]['deliver_status']){
                case 0:
                    $status = "已完成";
                    break;
                case 1:
                    $status = "生产中";
                    break;
                case 2:
                    $status = "未下单";
                    break;
                case 3:
                    $status = "待组装";
                    break;
                case 4:
                    $status = "组装中";
                    break;
                default:
                    $status = "";
                    break;
            }
            $phpexcel->getActiveSheet()->setCellValue("F".$rowIndex,$status);
            if($data[$i]['is_status'] == 0){
                $isstatus = '未发货';
            }else if($data[$i]['is_status'] == 1){
                $isstatus = '已发货';
            }
            $phpexcel->getActiveSheet()->setCellValue("G".$rowIndex,$isstatus);
            $phpexcel->getActiveSheet()->setCellValue("H".$rowIndex,$data[$i]['model_type']);
            $phpexcel->getActiveSheet()->setCellValue("I".$rowIndex,$data[$i]['model_num']);
            $phpexcel->getActiveSheet()->setCellValue("J".$rowIndex,$data[$i]['model_qty']);
            $phpexcel->getActiveSheet()->setCellValue("K".$rowIndex,$data[$i]['model_start']);
            $phpexcel->getActiveSheet()->setCellValue("L".$rowIndex,$data[$i]['model_end']);
            $phpexcel->getActiveSheet()->setCellValue("M".$rowIndex,$data[$i]['order_qty']);
            $phpexcel->getActiveSheet()->setCellValue("N".$rowIndex,$data[$i]['order_num']);
            $phpexcel->getActiveSheet()->setCellValue("O".$rowIndex,$data[$i]['assem_start']);
            $phpexcel->getActiveSheet()->setCellValue("P".$rowIndex,$data[$i]['assem_end']);
            $phpexcel->getActiveSheet()->setCellValue("Q".$rowIndex,$data[$i]['meter_len']);
            $meters = $data[$i]['meter_start']."~".$data[$i]['meter_end'];
            $phpexcel->getActiveSheet()->setCellValue("R".$rowIndex,$meters);
            $phpexcel->getActiveSheet()->setCellValue("S".$rowIndex,$data[$i]['manufacturer']);
            $phpexcel->getActiveSheet()->setCellValue("T".$rowIndex,$data[$i]['product_principle']);
            if($data[$i]['data_verify'] == 0){
                $dataVerify = "否";
            }else{
                $dataVerify = "是";
            }
            $phpexcel->getActiveSheet()->setCellValue("U".$rowIndex,$dataVerify);
            $sum = $data[$i]['sum_amounts']." ".$data[$i]['sum_units'];
            $phpexcel->getActiveSheet()->setCellValue("V".$rowIndex,$sum);
            $phpexcel->getActiveSheet()->setCellValue("W".$rowIndex,$data[$i]['comments']);
            //设置默认行高
            $phpexcel->getActiveSheet($rowIndex)->getDefaultRowDimension()->setRowHeight(30);
            $rowIndex++;
        }

        //导出属性设置
        $date = date('Ymd', time());
        $outputFileName = "订单执行表-".$date.".xlsx";
        //require_once("Classes/PHPExcel/Writer/Excel2007.php");
        ob_end_clean();//清除缓冲区,避免乱码
        $objWriter = new \PHPExcel_Writer_Excel2007($phpexcel, 'Excel2007');
        header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
        header("Content-Type: application/download");
        header('Content-Disposition:inline;filename="'.$outputFileName);
        header("Content-Transfer-Encoding: binary");
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Pragma: no-cache");
        $objWriter->save('php://output');
    }

    /**
     * 导出订单excel---订单评审
     * @throws \PHPExcel_Exception
     * @throws \PHPExcel_Writer_Exception
     */
    public function exportOrder($data){
        Vendor('phpexcel.PHPExcel');
        Vendor('phpexcel.PHPExcel.IOFactory');
        Vendor('phpexcel.PHPExcel.Reader.Excel5');
        Vendor('phpexcel.PHPExcel.Writer.Excel2007');

        $phpexcel = new \PHPExcel();
        $phpexcel->getActiveSheet()->setTitle("订单评审表");
        //var_dump($phpCreate);exit();
        // 设置单元格高度
        // 所有单元格默认高度
        $phpexcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(25);
        // 第一行的默认高度
        $phpexcel->getActiveSheet()->getRowDimension('1')->setRowHeight(30);
        // 垂直居中
        $phpexcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
        // 设置水平居中
        $phpexcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        //Excel表格式
        $letter = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y');
        //设置表头
        $tableheader = array('订单评审编号','国家','客户','客户联系方式','下单联系人','联系人电话','添加时间','内置止回阀','内置滤网',
            '铭牌信息','是否带唛头','业务部门','固定/动态信道','红外开关','出厂阀门状态','计量模式','报警量','透支量','时区',
            '软件来源','表号长度','方案','基表型号','基表对应数量','备注');
        //填充表头信息
        for($i = 0;$i < count($tableheader);$i++) {
            $phpexcel->getActiveSheet()->setCellValue("$letter[$i]1","$tableheader[$i]");
            //$phpexcel->getActiveSheet()->getColumnDimension($letter[$i])->setWidth($tablestyle[$i]['width']);
        }
        //设置标题字体加粗和大小
        $phpexcel->getActiveSheet()->getStyle( 'A1:Y1')->getFont()->setSize(12);
        $phpexcel->getActiveSheet()->getStyle( 'A1:Y1')->getFont()->setBold(true);
        $phpexcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('E')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('J')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('L')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('M')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('N')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('O')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('P')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('Q')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('R')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('S')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('T')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('U')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('V')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('W')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('X')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('Y')->setWidth(15);
        //数据
        //填充表格信息
        $rowIndex = 2;
        for ($i=0;$i<count($data);$i++) {
            $phpexcel->getActiveSheet()->setCellValue("A".$rowIndex,$data[$i]['oid']);
            $phpexcel->getActiveSheet()->setCellValue("B".$rowIndex,$data[$i]['state']);
            $phpexcel->getActiveSheet()->setCellValue("C".$rowIndex,$data[$i]['client']);
            $phpexcel->getActiveSheet()->setCellValue("D".$rowIndex,$data[$i]['client_contacts']);
            $phpexcel->getActiveSheet()->setCellValue("E".$rowIndex,$data[$i]['order_placer']);
            $phpexcel->getActiveSheet()->setCellValue("F".$rowIndex,$data[$i]['placer_phone']);
            $phpexcel->getActiveSheet()->setCellValue("G".$rowIndex,$data[$i]['create_time_o']);
            $phpexcel->getActiveSheet()->setCellValue("H".$rowIndex,$data[$i]['valve']);
            $phpexcel->getActiveSheet()->setCellValue("I".$rowIndex,$data[$i]['sieve']);
            $phpexcel->getActiveSheet()->setCellValue("J".$rowIndex,$data[$i]['nameplate']);
            $phpexcel->getActiveSheet()->setCellValue("K".$rowIndex,$data[$i]['mark']);
            $phpexcel->getActiveSheet()->setCellValue("L".$rowIndex,$data[$i]['sale']);
            $phpexcel->getActiveSheet()->setCellValue("M".$rowIndex,$data[$i]['chain']);
            $phpexcel->getActiveSheet()->setCellValue("N".$rowIndex,$data[$i]['infrade']);
            $phpexcel->getActiveSheet()->setCellValue("O".$rowIndex,$data[$i]['valve_status']);
            if($data[$i]['measure_mode'] == 0){
                $mode = "按体积";
            }else{
                $mode = "按金额";
            }
            $phpexcel->getActiveSheet()->setCellValue("P".$rowIndex,$mode);
            $phpexcel->getActiveSheet()->setCellValue("Q".$rowIndex,$data[$i]['alarm']);
            $phpexcel->getActiveSheet()->setCellValue("R".$rowIndex,$data[$i]['overdraft']);
            $phpexcel->getActiveSheet()->setCellValue("S".$rowIndex,$data[$i]['timezone']);
            $phpexcel->getActiveSheet()->setCellValue("T".$rowIndex,$data[$i]['soft_from']);
            $phpexcel->getActiveSheet()->setCellValue("U".$rowIndex,$data[$i]['meter_len']);
            $phpexcel->getActiveSheet()->setCellValue("V".$rowIndex,$data[$i]['pro_name']);
            $phpexcel->getActiveSheet()->setCellValue("W".$rowIndex,$data[$i]['meters']);
            $phpexcel->getActiveSheet()->setCellValue("X".$rowIndex,$data[$i]['order_qty']);
            $phpexcel->getActiveSheet()->setCellValue("Y".$rowIndex,$data[$i]['other']);
            //设置默认行高
            $phpexcel->getActiveSheet($rowIndex)->getDefaultRowDimension()->setRowHeight(30);
            $rowIndex++;
        }

        //导出属性设置
        $date = date('Ymd', time());
        $outputFileName = "订单评审表-".$date.".xlsx";
        //require_once("Classes/PHPExcel/Writer/Excel2007.php");
        ob_end_clean();//清除缓冲区,避免乱码
        $objWriter = new \PHPExcel_Writer_Excel2007($phpexcel, 'Excel2007');
        header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
        header("Content-Type: application/download");
        header('Content-Disposition:inline;filename="'.$outputFileName);
        header("Content-Transfer-Encoding: binary");
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Pragma: no-cache");
        $objWriter->save('php://output');
    }

    /**
     * 导出订单excel---配件执行
     * @throws \PHPExcel_Exception
     * @throws \PHPExcel_Writer_Exception
     */
    public function exportExec($data){
        Vendor('phpexcel.PHPExcel');
        Vendor('phpexcel.PHPExcel.IOFactory');
        Vendor('phpexcel.PHPExcel.Reader.Excel5');
        Vendor('phpexcel.PHPExcel.Writer.Excel2007');

        $phpexcel = new \PHPExcel();
        $phpexcel->getActiveSheet()->setTitle("配件执行表");
        //var_dump($phpCreate);exit();
        // 设置单元格高度
        // 所有单元格默认高度
        $phpexcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(25);
        // 第一行的默认高度
        $phpexcel->getActiveSheet()->getRowDimension('1')->setRowHeight(30);
        // 垂直居中
        $phpexcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
        // 设置水平居中
        $phpexcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        //Excel表格式
        $letter = array('A','B','C','D','E','F','G','H','I');
        //设置表头
        $tableheader = array('订单评审编号 ','国家','客户','配件','配件数量','下单联系人','生产状态','生产负责人','备注');
        //填充表头信息
        for($i = 0;$i < count($tableheader);$i++) {
            $phpexcel->getActiveSheet()->setCellValue("$letter[$i]1","$tableheader[$i]");
            //$phpexcel->getActiveSheet()->getColumnDimension($letter[$i])->setWidth($tablestyle[$i]['width']);
        }
        //设置标题字体加粗和大小
        $phpexcel->getActiveSheet()->getStyle( 'A1:I1')->getFont()->setSize(12);
        $phpexcel->getActiveSheet()->getStyle( 'A1:I1')->getFont()->setBold(true);
        $phpexcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
//        $phpexcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); //宽度自适应
        $phpexcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('E')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
        //数据
        //填充表格信息
        $rowIndex = 2;
        for ($i=0;$i<count($data);$i++) {
            $phpexcel->getActiveSheet()->setCellValue("A".$rowIndex,$data[$i]['oid']);
            $phpexcel->getActiveSheet()->setCellValue("B".$rowIndex,$data[$i]['state']);
            $phpexcel->getActiveSheet()->setCellValue("C".$rowIndex,$data[$i]['client']);
            $phpexcel->getActiveSheet()->setCellValue("D".$rowIndex,$data[$i]['fitting']);
            $phpexcel->getActiveSheet()->setCellValue("E".$rowIndex,$data[$i]['fid_num']);
            $phpexcel->getActiveSheet()->setCellValue("F".$rowIndex,$data[$i]['order_placer']);
            if($data[$i]['deliver_status'] == 0){
                $status = '已执行';
            }else if($data[$i]['deliver_status'] == 1){
                $status = '生产中';
            }else{
                $status = '未执行';
            }
            $phpexcel->getActiveSheet()->setCellValue("G".$rowIndex,$status);
            $phpexcel->getActiveSheet()->setCellValue("H".$rowIndex,$data[$i]['product_principle']);
            $phpexcel->getActiveSheet()->setCellValue("I".$rowIndex,$data[$i]['other']);
            //设置默认行高
            $phpexcel->getActiveSheet($rowIndex)->getDefaultRowDimension()->setRowHeight(30);
            $rowIndex++;
        }

        //导出属性设置
        $date = date('Ymd', time());
        $outputFileName = "配件执行表-".$date.".xlsx";
        //require_once("Classes/PHPExcel/Writer/Excel2007.php");
        ob_end_clean();//清除缓冲区,避免乱码
        $objWriter = new \PHPExcel_Writer_Excel2007($phpexcel, 'Excel2007');
        header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
        header("Content-Type: application/download");
        header('Content-Disposition:inline;filename="'.$outputFileName);
        header("Content-Transfer-Encoding: binary");
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Pragma: no-cache");
        $objWriter->save('php://output');
    }

    /**
     * 导出订单excel--客供料执行
     * @throws \PHPExcel_Exception
     * @throws \PHPExcel_Writer_Exception
     */
    public function exportSupply($data){
        Vendor('phpexcel.PHPExcel');
        Vendor('phpexcel.PHPExcel.IOFactory');
        Vendor('phpexcel.PHPExcel.Reader.Excel5');
        Vendor('phpexcel.PHPExcel.Writer.Excel2007');

        $phpexcel = new \PHPExcel();
        $phpexcel->getActiveSheet()->setTitle("客供料执行表");
        //var_dump($phpCreate);exit();
        // 设置单元格高度
        // 所有单元格默认高度
        $phpexcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(25);
        // 第一行的默认高度
        $phpexcel->getActiveSheet()->getRowDimension('1')->setRowHeight(30);
        // 垂直居中
        $phpexcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
        // 设置水平居中
        $phpexcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        //Excel表格式
        $letter = array('A','B','C','D','E','F','G','H','I');
        //设置表头
        $tableheader = array('客供料编号','国家','客户','模块型号','订单数量','配件','客供料型号','供应商','采购状态');

        //填充表头信息
        for($i = 0;$i < count($tableheader);$i++) {
            $phpexcel->getActiveSheet()->setCellValue("$letter[$i]1","$tableheader[$i]");
            //$phpexcel->getActiveSheet()->getColumnDimension($letter[$i])->setWidth($tablestyle[$i]['width']);
        }
        //设置标题字体加粗和大小
        $phpexcel->getActiveSheet()->getStyle( 'A1:I1')->getFont()->setSize(12);
        $phpexcel->getActiveSheet()->getStyle( 'A1:I1')->getFont()->setBold(true);
        $phpexcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('E')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
        $phpexcel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
        //数据
        //填充表格信息
        $rowIndex = 2;
        for ($i=0;$i<count($data);$i++) {

            $phpexcel->getActiveSheet()->setCellValue("A".$rowIndex,$data[$i]['mod_sup_id']);
            $phpexcel->getActiveSheet()->setCellValue("B".$rowIndex,$data[$i]['state']);
            $phpexcel->getActiveSheet()->setCellValue("C".$rowIndex,$data[$i]['client']);
            $phpexcel->getActiveSheet()->setCellValue("D".$rowIndex,$data[$i]['model_type']);
            $phpexcel->getActiveSheet()->setCellValue("E".$rowIndex,$data[$i]['order_qty']);
            if($data[$i]['fitid'] == 0){
                $fitting = '/';
            }else{
                $fitting = $data[$i]['fitting'];
            }
            $phpexcel->getActiveSheet()->setCellValue("F".$rowIndex,$fitting);
            $phpexcel->getActiveSheet()->setCellValue("G".$rowIndex,$data[$i]['sup_type']);
            $phpexcel->getActiveSheet()->setCellValue("H".$rowIndex,$data[$i]['provider']);
            if($data[$i]['product_status'] == 0){
                $status = '未采购';
            }else if($data[$i]['product_status'] == 1){
                $status = '采购中';
            }else{
                $status = '已采购';
            }
            $phpexcel->getActiveSheet()->setCellValue("I".$rowIndex,$status);

            //设置默认行高
            $phpexcel->getActiveSheet($rowIndex)->getDefaultRowDimension()->setRowHeight(30);
            $rowIndex++;
        }

        //导出属性设置
        $date = date('Ymd', time());
        $outputFileName = "客供料执行表-".$date.".xlsx";
        //require_once("Classes/PHPExcel/Writer/Excel2007.php");
        ob_end_clean();//清除缓冲区,避免乱码
        $objWriter = new \PHPExcel_Writer_Excel2007($phpexcel, 'Excel2007');
        header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
        header("Content-Type: application/download");
        header('Content-Disposition:inline;filename="'.$outputFileName);
        header("Content-Transfer-Encoding: binary");
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Pragma: no-cache");
        $objWriter->save('php://output');
    }



}